home *** CD-ROM | disk | FTP | other *** search
/ The AGA Experience 3 / AGA Experience Volume 3 (1997)(NFA - SAdENESS)[!].iso / software / utilities / misc / atebeta5b / source-code / atebeta5source.readme < prev    next >
Encoding:
Text File  |  1996-05-05  |  10.6 KB  |  224 lines

  1. 6 MAY 96
  2.  
  3. This source is a public release to Aminet and is for the Amiga
  4. Typeface Engine Beta5B, also available now on Aminet.  This is
  5. now freely distributable code, superceeding any previous
  6. restrictions.
  7.  
  8. Now with the preamble out of the way let me get one request out:
  9.  
  10. I may still work on ATE from time to time.  In particular I want
  11. to finish the AFM corrector, unless you have a better alternative.
  12. If you want to add a feature, check to see if I didn't do it first.
  13. It'll save you a whole lot of trouble re-inventing the wheel. :)
  14.  
  15. _______Archive contents:
  16.  
  17. ATEbeta5B.c           Latest version of source code, includes
  18.                       patch for NewScaledDiskFont().  This is
  19.                       the main engine and is essentially finished,
  20.                       except for replacing the dumb console
  21.                       window with nice AutoRequesters.  This works
  22.                       with all versions of post.library from V15,
  23.                       including HWGPOST.  You will need to swap
  24.                       the "hwgpostlib.h" with "postlib.h" if you
  25.                       are using the old headers from Pre-V22 POST.
  26.  
  27. ATMbeta1A.c           A very old, practically unreleased, version
  28.                       of the source that used a routine in
  29.                       PostScript, instead of AFMs, to obtain the
  30.                       character dimensions.  Using AFMs is
  31.                       far better, but AFMs may be inaccurate or
  32.                       missing font bounding box info.  Notice also
  33.                       PS mistakes I corrected in ATEbeta5.  Use
  34.                       this version to learn how to extract character
  35.                       bounding boxes without AFMs if you wish, and
  36.                       don't be afraid to make your own AFM corrector.
  37.  
  38. FixAFM.c              A shell of code that initalizes the PS library
  39.                       for preparation of reading bounding box info.
  40.                       Use this combined with code from ATMbeta1A to
  41.                       make your own AFM corrector.
  42.  
  43. atmDevLog.txt         My development log from the very first day I
  44.                       got my copy of DICE C 3.0.  Notice that all
  45.                       the source code here works on DICE C 3.0 or
  46.                       better, and the patches use registerized
  47.                       parameters for the patch functions.  This will
  48.                       require translation to SAS C if you use this
  49.                       instead of DICE.
  50.  
  51. ATEbeta5GUI.gui       A user interface I designed using GadToolsBox
  52.                       version 2.0b.  If you want to redo it from
  53.                       scratch that's up to you.  However, YOU MUST
  54.                       AVOID M.U.I. AT ALL COSTS!!!!!!  This thing
  55.                       runs on a 68000 and I want it to stay that way!
  56.  
  57. Now for some details:
  58.  
  59. ________Registerized Parameters
  60.  
  61. As I wrote above, this code works compiled with DICE 3.0.  The patches
  62. work by using registerized parameters and making sure the library base
  63. is in A6 before calling the original function.  I find this works
  64. very well and reliably, even for the otherwise risky Text() patch.
  65. DICE code generators automatically save D2-D7 and A2-A6 before running
  66. the actual function, and restore these registers before returning,
  67. and automatically return any results or pointers in D0.  Very handy!
  68.  
  69. Also regarding the patches, I have all PostScript processing occur in
  70. ATE's main process, such as not to over-load any programs that call on
  71. the patched functions.  I use EXEC messages for this and global pointers
  72. to the message ports.  This is critical especially for the Text() patch
  73. where many non-Processes call upon it, and I can only make AmigaDOS calls
  74. from within Processes.  This may appear to bog down the PostScript engine
  75. but it manages to run quite smoothly.  
  76.  
  77. _______Big Problem Patch
  78.  
  79. One patch has turned into a nightmare; the AvailFonts() patch.  This one
  80. actually inserts ATE TextAttr structs inside the memory space set up by
  81. the program's caller.  The logic works like this:
  82.  
  83. 0) (Before patching) ATE finds out how much space a AvailFonts() call
  84.    would take for diskfonts, then remembers that value
  85.  
  86. 1) Program calls AvailFonts() with its buffer and settings
  87.  
  88. 2) ATE determines if the caller's buffer is big enough (including for
  89.    already-loaded fonts and ROM fonts) and if it's not big enough,
  90.    return the # of bytes extra needed.  Some programs deliberately
  91.    call AvailFonts with a zero length buffer causing a font scan to happen
  92.    twice.  ATE may otherwise cause three or four font scans if I did not
  93.    pre-determine the disk font size.
  94.  
  95. 3) ATE calls the original AvailFonts fcn with the buffer somewhere in
  96.    the middle of the caller's buffer, like this:
  97.  
  98. |-dfheader-|-ATE reserved-|-AmigaDFheader-|-AmigaFonts-|-ATE reserved-|
  99.  
  100. 4) ATE counts the number of Amiga diskfonts and builds a new dfheader,
  101.    then inserts ATE fonts at the start of the list, and the text for the
  102.    font names at the end:
  103.  
  104. |-dfHeader-|-ATEfonts-|-AmigaFonts-|-ATEfontnames-|
  105.  
  106. 5) ATE returns a zero indicating success.
  107.  
  108. This technique works with many programs, but it fails with these:
  109.  
  110. DeluxePaint IV non-AGA: Some Amiga diskfonts are missing at the end
  111.  
  112. FED 1.3 (Old font editor): Many font names are destroyed
  113.  
  114. Apparently, also Final Copy/Final Writer crash instantly on startup
  115. with this one patch active.
  116.  
  117. I tried to account for both TTextAttrs and TextAttrs (With pre-defined
  118. tags for ATE fonts) and I know that Excellence! 3.0 and asl.library
  119. font requesters work with this, showing all fonts.  I cannot tell
  120. why DeluxePaint IV non-AGA is the only program that doesn't like it.
  121.  
  122. _________Having PostScript code call ATE
  123.  
  124. Only functions called by post.lib's callextfunc operator require
  125. stack-based calls.  Later on, if you choose to make PS code call
  126. functions within ATE, use Heinz Wrobel's @calluserhook operator and
  127. create a Hook structure, using a registerized function as an entry
  128. point.  This will be important with any AFM corrector written once
  129. Heinz eliminates callextfunc.  Check out the old ATMbeta1 source for
  130. calextfunc examples.
  131.  
  132. Currently, no code in ATE uses this operator, to avoid problems once
  133. Heinz finally removes it.  Any AFM corrector will need to use
  134. @calluserhook to grab glyph dimensions.
  135.  
  136. _________Using AFMs to speed up the process
  137.  
  138. ATE pre-determines how much memory a bitmap will take based on the
  139. font size selected, and each character's dimensions, based on its
  140. AFM's contents.  Adrian Aylward's old MKBMAP program, which ATE was
  141. based on, obtained this right from the typeface itself.  I use AFMs
  142. because of reduced processing time needed (why reproduce what's already
  143. available?) and to improve the kerning of italicized typefaces.  Check
  144. out Times-Italic, type a few lower case "f"s and "g"s and see for yourself.
  145. This kind of manipulation will be critical for "script" typefaces and
  146. other spacing-picky typefaces.
  147.  
  148. How much space a character is SUPPOSED to take is determined by the WX
  149. value in a given metric.  The Amiga equivelant is the tf_CharSpace array.
  150. This information only exists in the metric file and NOWHERE ELSE.
  151. Not even in the typeface itself.
  152.  
  153. Characters may overlap in front of, or behind, its designated space.
  154. PostScript uses an arbitrary scale of 0 to 1000 to define a character's
  155. "living space".  Characters may exceed this by design and you will
  156. notice this with negative numbers, or numbers greater than 1000, in
  157. a metric's B values (B xxx xxx xxx xxx).  On The Amiga, characters
  158. like this will have wider dimensions in the tf_CharLoc array, than its
  159. tf_CharSpace value.  It will also have a tf_CharKern value appropriate;
  160. negative if it "hangs" left (like a lower case italic f) or positive if
  161. it has leading spacing (not likely in most typefaces).
  162.  
  163. ATE will reserve just enough memory for each character.  If the AFMs are
  164. inaccurate, you might notice pieces of one character intruding on
  165. another.  This is where AFM accuracy is critical!  Typefaces from Adobe
  166. Systems will have accurate AFMs, as ATM for The Macintosh relies on this
  167. info as well!  Typefaces from third parties, or from Windows packages,
  168. will have inaccurate AFMs, or PFMs that don't include B parameters.
  169. (OK so I lied.  Metric info is stored on Macs in a FOND resource which
  170. is a binary copy of what's in the AFM file.)
  171.  
  172. Somewhere on The Internet exists a program called "pfm2afm" which
  173. generates a text AFM file out of an MS-Windows PFM file.  PFMs contain
  174. much of the info ATE needs except the bounding boxes!  This is one
  175. reason why an AFM corrector is necessary.  The program was originally
  176. written for IBM OS/2, but an Amiga version exists.  Ask me if you can't
  177. find it.  I didn't include it here because of copyrights.
  178.  
  179. Since a great deal of PostScript typefaces come with PFM files instead
  180. of AFM files (or come with inaccurate AFM files) converting one of these
  181. metric files becomes a two step process; Convert the PFM to an AFM, then
  182. correct the new AFM based on the typeface itself.
  183.  
  184. ________Ideas for a Typeface Installer
  185.  
  186. A typeface installer should look for PFMs and AFMs when installing 
  187. typefaces.  It should be able to search an entire floppy disk or CD-ROM
  188. for these files.  The matching typefaces will either have an extension
  189. of .PFB, .PFA, or no extension at all.  It is possible to issue a LIST
  190. command at a CLI like this:
  191.  
  192. List CD0:#?.PFM ALL >T:listFile.txt
  193.  
  194. The list file will give a breakdown of the directory structure and all
  195. the requested files within.  You can then determine where the typefaces
  196. are by using the filenames of the .PFM or .AFM files.
  197.  
  198. The installer can then perform any conversions or corrections needed
  199. and generate a _ATE_#? file for it.
  200.  
  201. A typeface installer should also be able to group typefaces into families.
  202. AFM files contain family info and should help match typefaces together.
  203. Adobe relies on this for ATM for The Mac and for Windows.  A family
  204. includes its "normal", "Bold", "Italic", and "BoldItalic" cousins.  
  205. For typefaces that have more than two weights, like Adobe Garamond, you
  206. can create additional groupings.  Worst case, if you can't account for
  207. various weights, is to pair off typefaces as "Regular" and "Italic"
  208. and have a font entry for each weight.
  209.  
  210. ________That's it
  211.  
  212. I so much wanted to turn this into Adobe Type Manager for the Amiga,
  213. but Adobe wouldn't allow it.  As such it turned into Amiga Type Engine
  214. but it is an unfinished beast.  Try to make this as much ATM as you
  215. can, and draw ideas from Adobe's product.  Their README files for their
  216. Windows product can give you needed insight into its operation.
  217.  
  218. Also remember you're depending on another coder's PostScript library
  219. to do this, this is so you can use more than just Type 1 typefaces
  220. or whatever.  ATE will end up being as good as the PostScript library
  221. is, so don't be afraid to bug Heinz Wrobel for improvements. :)
  222.  
  223. Gordon Fecyk
  224.